{include file="public_head"}
<script type="text/javascript" src="__STATIC__/js/a.js"></script>
<script type="text/javascript" src="/static/plupload/plupload.full.min.js"></script>
  <div class="content_center">
    <div class="main_center">
      <div class="main_right right">
        <div class="main_right_title">评价晒单
        </div>
        <div class="order_content">
          <div class="center-eva">
            <div class="content">
              <div class="title">
                <h4>评价订单</h4>
                <p>订单号：{$order['order_number']}    {:date('Y-m-d H:i:s',$order['create_time'])}</p>
              </div>
              <div class="main">
                <div class="left">
                  <img src="/{$attached['thumb_img']}">
                  <h4>{$attached['title']}</h4>
                  <span>{$attached['attr']}</span>
                  <p>{$price}元</p>
                </div>
                <div class="right">
                  <div class="time">
                  </div>
                  <div class="satisfy">
                    <div><p>商品满意度</p></div>
                    <div class="star">
                      <div id="starttwo" class="block clearfix">
                        <div  class="star_score"></div>
                        <p style="float:left;"><span class="fenshu" id="fenshu"></span>分</p>
                      </div>
                    </div>
                  </div>
                  <div><p>评价晒单</p></div>
                  <div>
                    <textarea placeholder="请留下你的评价吧～" id="content" rows="6" cols="42"></textarea>
                  </div>
                  <div class="review">
                    <ul class="photo" style="width: 600px;">

                      <li id="btn">
                        <img src="__STATIC__/img/bg27.png" style="height: 80px;width: 80px;">
                      </li>
                      <ul id="ul_pics"></ul>
                      <div id="img2"><input name='picArr[]' id="picArr[]" type='hidden' value=''></div>
                      <div class="cl"></div>
                    </ul>
                  </div>

                </div>

              </div>

              <div class="submit">
                <div>
                  <input type="hidden" value="{$order_id}" id="order_id">
                  <input type="hidden" value="{$aid}" id="aid">
                  <input type="hidden" value="{$attached['goods_id']}" id="good_id">
                  <input type="hidden" value="{$attached['title']}" id="title">
                  <input type="hidden" value="{$attached['attr']}" id="attr">
                  <input type="hidden" value="{$attached['thumb_img']}" id="thumb_img">
                  <input type="submit" value="提交" onclick="aaa()">
                  <!--<div>-->
                    <!--<input type="checkbox" class="checkbox" id="radio-1-1"><label for="radio-1-1">匿名评价</label>-->
                  <!--</div>-->
                </div>
              </div>

            </div>
          </div>
        </div>
      </div>

    </div>
  </div>
<script>
  // 五星好平
  scoreFun($("#startone"))
  scoreFun($("#starttwo"),{
    fen_d:36,//每一个a的宽度
    ScoreGrade:5//a的个数 10或者
  });

  // 取消上传图片
  function img_del(id, picUrl, url) {

    $.ajax({
      url: url,
      type: 'post',
      dataType: 'json',
      data: {picUrl: picUrl},
      async: true,
      success: function (data) {

        if (data.code == '200') {
          $("#" + id).remove('');
          layer.msg(data.message);
        } else {
          layer.msg(data.message);
          return false;
        }


      }
    });
  }

  // 提交表单
  function aaa() {
    var pic_arr = [];
    $("input[name=picArr]").each(function (i,o) {
      pic_arr[i] = $(o).val();
    });

    // 评分 评价内容
    var grade = $('#fenshu').html();
    var order_id = $('#order_id').val();
    var content = $('#content').val();
    var good_id = $('#good_id').val();
    var attr = $('#attr').val();
    var title = $('#title').val();
    var thumb_img = $('#thumb_img').val();
    if (grade=='') {
      layer.msg('评分不能为空');
      return false;
    }
    if (content=='') {
      layer.msg('评论内容不能为空！');
      return false;
    }

    $.ajax({
      url: "{:url('shop/member_order/goods_evaluate')}",
      dataType: 'json',
      type: 'post',
      data: {'grade': grade, 'content': content,'order_id':order_id,'pic_arr':pic_arr,'good_id':good_id,'title':title,'attr':attr,'thumb_img':thumb_img},
      success: function (t) {
        if (t.code == 200) {
          layer.msg('评价成功', {icon: 1});
          window.location.href = "{:url('shop/member_order/index')}";
        } else {
          layer.msg(t.message);
        }

      }
    })
  }
  var uploader = new plupload.Uploader({
    runtimes: 'html5,flash,silverlight,html4',
    browse_button: 'btn',
    url: "{:url('shop/member_order/uploadImg')}",
    flash_swf_url: '__STATIC__/wap/js/plupload/Moxie.swf',
    silverlight_xap_url: '__STATIC__/wap/js/plupload/Moxie.xap',
    filters: {
      max_file_size: '2048kb',
      mime_types: [
        {title: "files", extensions: "jpg,png,gif,jpeg,PNG,JPG,JPEG,GIF"}
      ]
    },
    multi_selection: true,
    init: {
      FilesAdded: function (up, files) {

        if ($("#ul_pics").children("li").length > 7) {
          layer.msg("您上传的图片太多了！");
          uploader.destroy();
        } else {
          var li = '';
          plupload.each(files, function (file) {
            li += "<li id='1" + file['id'] + "'><div class='progress'style='height: 8px;width: 80px;'><span class='bar'></span><span class='percent'>0%</span></div></li>";
          });
          $("#ul_pics").append(li);
          uploader.start();

        }
      },
      UploadProgress: function (up, file) {
        var percent = file.percent;
        $("#1" + file.id).find('.bar').css({"width": percent + "%"});
        $("#1" + file.id).find(".percent").text(percent + "%");
      },
      FileUploaded: function (up, file, info) {
        if ($("#ul_pics").children("li").length > 6) {
          layer.msg("最多只能上传6张图片！");
          $("#1" + file.id).remove('');
          return false;
          uploader.destroy();
        }
        document.getElementById('img2').innerHTML = '';

//                        var data = JSON.parse(info.response);
        var data = eval("(" + info.response + ")");
        $("#1" + file.id).html("<img style='height: 80px;width: 80px;float: left;margin-bottom: 10px;' src='/" + data.picUrl + "'/><input name='picArr' id='picArr[]' type='hidden' value='" + data.picUrl + "'><a style='float: right;margin-top:-5px;position:absolute;margin-left: -10px; ' onclick=img_del('1" + file.id + "','" + data.picUrl + "','{:url(\'member_order/uploadImgDestroy\')}')><img style='height: 10px; width: 10px;' src='__STATIC__/img/icon22.png'/></a>");
      },
      Error: function (up, err) {
        layer.msg('服务器异常,请重新上传');
      }
    }
  });
  uploader.init();
</script>
{include file="public_foot"}